package com.zky.kafka.producer;

import com.zky.kafka.domin.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.kafka.support.SendResult;
import org.springframework.stereotype.Service;
import org.springframework.util.concurrent.ListenableFuture;

@Service
public class KafkaProducer {
    @Autowired
    private KafkaTemplate<Object, Object> kafkaTemplate;

    public ListenableFuture<SendResult<Object, Object>> send(String topic, Object message) {
        ListenableFuture<SendResult<Object, Object>> send = kafkaTemplate.send(topic, message);
        return send;
    }
}
